/*
 * 
 */
package milecToMinisat;


/** 
 * IntegerVariable contains datas to be known about an integer variable. 
 *  
 * @author ter-topcased-ups
 * @version 0.01, 2008/13/03
 * @see 
 */
public class IntegerVariable implements IntegerExp {

		public String name ;
		/** maximal value of the variable (inclusive) */
		/*  MUST NOT be modified without using accessor */ 
		private Integer bound ;
		/** number of bits on which variable is encoded in minisat */
		/*  calculated from size,  MUST NOT be modified */ 
		private int size ;
		private static int tmpVarCounter = 0 ;
		
		IntegerVariable(String name, int bound) {
			this.name = name ;
			this.setBound(bound) ;
		}
		
		public static IntegerVariable tempVar(int size) {
			return new IntegerVariable(getTempName(),util.MathPerso.pow(2,size)  )  ;
		}
		
		public int getBound()  {
			return this.bound ;
		}
		
		public void  setBound(int bound)  {
			this.bound =  new Integer(bound) ;
			this.size = 32 - Integer.numberOfLeadingZeros(this.bound) ;
		}
		
		public int getSize () {
			return this.size ;
		}
		
		private static String getTempName () {
			return "tmpInt"+(tmpVarCounter++) ;
		}
}
